home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / DTS.Lib.protos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  74.5 KB  |  2,022 lines  |  [TEXT/MPS ]

  1. #ifndef __DLPROTOS__
  2. #define __DLPROTOS__
  3.  
  4. #ifndef __APPLEEVENTS__
  5. #include <AppleEvents.h>
  6. #endif
  7.  
  8. #ifndef __APPLETALK__
  9. #include <AppleTalk.h>
  10. #endif
  11.  
  12. #ifndef __LISTS__
  13. #include <Lists.h>
  14. #endif
  15.  
  16. #ifndef __MENUS__
  17. #include <Menus.h>
  18. #endif
  19.  
  20. #ifndef __PPCTOOLBOX__
  21. #include <PPCToolbox.h>
  22. #endif
  23.  
  24. #ifndef __STANDARDFILE__
  25. #include <StandardFile.h>
  26. #endif
  27.  
  28.  
  29. /*****************************************/
  30. /************** AEConnect.c **************/
  31. /*****************************************/
  32.  
  33.  
  34.  
  35. void            InitConnectAppleEvents(void);
  36.     /* This function initializes the connect AppleEvents stuff.  It needs to be
  37.     ** called so that DTS.framework applications can connect with other applications
  38.     ** specific to a targeted window. */
  39.  
  40.  
  41.  
  42. OSErr            SendConnect(FileRecHndl frHndl, char *theLocNBPType);
  43.     /*
  44.     ** INPUT:    frHndl            This is the document reference that will contain the
  45.     **                            connect information if a connection is established.
  46.     **            theLocNBPType    You may have registered an NBPAlias for the application.
  47.     **                            If so, then you may pass in an alias to this function.
  48.     **                            (Just a pascal-string.)  If you aren't using aliases,
  49.     **                            then pass in nil.
  50.     ** RESULT:    OSErr
  51.     **
  52.     ** This is the function that is called to establish a connection to another
  53.     ** DTS.framework-based application.  The "other" DTS.framework application is probably
  54.     ** the same application on another machine.  This code does a bit more than simply
  55.     ** connecting to another application.  It targets a specific window within that
  56.     ** application. It doesn’t just target zone-machine-application, which is the
  57.     ** granularity that AppleEvents gives you.  It also passes back and forth some
  58.     ** information that is kind of a pain to get, but is nice to have.  One such piece of
  59.     ** information is the user name.  This needs to be sent.  It can’t be determined from
  60.     ** the message from an AppleEvent.  The sender sends the user name, and the receiver
  61.     ** returns the remote user name.  The user name is placed in the document record for
  62.     ** the window to be used if you wish. */
  63.  
  64.  
  65.  
  66. WindowPtr        GetAEWindow(long windID_0, long windID_1);
  67.     /*
  68.     ** INPUT:    windID_0, windID_1        This function is called to determine which window,
  69.     **                                    if any, is the designated target window.  The
  70.     **                                    window ID’s are determined when the connection is
  71.     **                                    established.  The framework uses this function to
  72.     **                                    identify the proper target window.  There is
  73.     **                                    probably not much reason for the application to
  74.     **                                    make this call. */
  75.  
  76.  
  77.  
  78. void            GetFullPathAndAppName(StringPtr path, StringPtr app);
  79.     /*
  80.     ** OUTPUT:    path    The full path of the application.  This is used, for example, in
  81.     **                    the sample DTS.StyleChat for telling a remote Finder to
  82.     **                    automatically launch an application.  The Finder demands a full
  83.     **                    path name for this AppleEvent.
  84.     **            app        The name of the application. */
  85.  
  86.  
  87.  
  88. void            AllowAutoReconnect(FileRecHndl frHndl);
  89.     /*
  90.     ** INPUT:    frHndl        The document that will allow auto-lanuch/reconnecting of
  91.     **                        the application.
  92.     **
  93.     ** This function should be called prior to calling SendConnect if you want to pass
  94.     ** the application being connected to the information necessary to remotely
  95.     ** restart the application.  The mutual information will be returned. */
  96.  
  97.  
  98.  
  99. pascal Boolean    AEPortFilter(LocationNamePtr locationName, PortInfoPtr thePortInfo);
  100.     /*
  101.     ** INPUT:    locationName    Unused by this implementation of the port filter.
  102.     **            thePortInfo        The port info record that is matched for determining if
  103.     **                            the PPCBrowser should filter the application or not.
  104.     **
  105.     ** This function filters out apps of type other than itself.  You can of course use a
  106.     ** different filter.  This is the default filter. */
  107.  
  108.  
  109.  
  110. typedef pascal Boolean    (*GRPTProcPtr)(LocationNamePtr locationName,
  111.                                        PortInfoPtr thePortInfo);
  112.     /* This prototype is used for writing your own DoIPCListPorts filter.  Look up
  113.     ** DoIPCListPorts for information on this function. */
  114.  
  115.  
  116.  
  117. OSErr            GetRemoteProcessTarget(FileRecHndl frHndl, AEDesc *retDesc,
  118.                                        GRPTProcPtr proc);
  119.     /*
  120.     ** INPUT:    frHndl        Get remote information from the machine that this document is
  121.     **                        connected to.
  122.     **            proc        The filter that is passed to DoIPCListPorts (which this
  123.     **                        function calls).
  124.     ** OUTPUT:    retDesc        Return the AEDesc of the remote target.
  125.     ** RESULT:    OSErr
  126.     **
  127.     ** Get the target of a remote process, given location information in the frHndl. */
  128.  
  129.  
  130.  
  131. OSErr            LaunchRemoteApp(FileRecHndl frHndl);
  132.     /*
  133.     ** INPUT:    frHndl    Assuming that the proper information is in the frHndl, then use
  134.     **                    this information to auto-launch the remote application.  Once
  135.     **                    launched, then the appcation can be connected to.
  136.     **                    (See DTS.StyleChat for an example of this being used.)
  137.     ** RESULT:    OSErr
  138.     */
  139.  
  140.  
  141.  
  142. /******************************************/
  143. /************** AERequired.c **************/
  144. /******************************************/
  145.  
  146.  
  147.  
  148. OSErr            InitRequiredAppleEvents(void);
  149.     /*
  150.     ** RESULT:    OSErr
  151.     **
  152.     ** Intializes AppleEvent dispatcher table for the required events.  It also
  153.     ** determines if the machine is PPCBrowser and AppleEvent capable.  If so,
  154.     ** the booleans gHasAppleEvents and gHasPPCToolbox are set true.  This function
  155.     ** must be the first AppleEvents initialization DTS.framework function called,
  156.     ** as the other functions depend on the booleans being set correctly. */
  157.  
  158.  
  159.  
  160. pascal OSErr    DoAEOpenApplication(AppleEvent *message, AppleEvent *reply, long refcon);
  161.     /*
  162.     ** INPUT:    message        AppleEvent for 'oapp' event.
  163.     **            reply        Reply for 'oapp' event.
  164.     **            refcon        Refcon for 'oapp' event.
  165.     **
  166.     ** This function is the standard AppleEvent handler installed by
  167.     ** InitRequiredAppleEvents.  You should never call this directly. */
  168.  
  169.  
  170. /***************************************/
  171. /************** AEUtils.c **************/
  172. /***************************************/
  173.  
  174.  
  175.  
  176. #ifndef         __AEUTILS__
  177. #include        "AEUtils.h"
  178. #endif
  179.  
  180.  
  181.  
  182. /**************************************/
  183. /************** AEWFMT.c **************/
  184. /**************************************/
  185.  
  186.  
  187.  
  188. void    InitWFMTAppleEvents(void);
  189.     /*
  190.     ** Install our custom AppleEvents for editing running applications.  This is done in
  191.     ** addition to installing the required AppleEvents.  InitAppleEvents, which installs
  192.     ** the required AppleEvents, must be called first, since it sets up some global
  193.     ** values. */
  194.  
  195.  
  196.  
  197. OSErr    SendWFMTMessage(FileRecHndl frHndl, TreeObjHndl wobj, short messageType,
  198.                         ResType rtype, short resID, Handle *resHndl, StringPtr suffix);
  199.     /*
  200.     ** INPUT:    frHndl
  201.     **            wobj
  202.     **            messageType
  203.     **            rtype
  204.     **            resID
  205.     **            suffix
  206.     ** OUTPUT:    resHndl
  207.     **
  208.     ** Send a message to the running application for various application-editing
  209.     ** functions.  This is used by the AppsToGo application editor for editing running
  210.     ** applications. You shouldn't need to call it unless you are writing a run-time
  211.     ** application editor. */
  212.  
  213.  
  214.  
  215. /***************************************/
  216. /************** ATUtils.c **************/
  217. /***************************************/
  218.  
  219.  
  220.  
  221. #ifndef         __ATUTILS__
  222. #include        "ATUtils.h"
  223. #endif
  224.  
  225.  
  226.  
  227. /********************************************/
  228. /************** CIconControl.c **************/
  229. /********************************************/
  230.  
  231.  
  232.  
  233. #ifndef         __CICONCONTROL__
  234. #include        "CIconControl.h"
  235. #endif
  236.  
  237.  
  238.  
  239. /******************************************/
  240. /************** CtlHandler.c **************/
  241. /******************************************/
  242.  
  243.  
  244.  
  245. #ifndef         __CTLHANDLER__
  246. #include        "CtlHandler.h"
  247. #endif
  248.  
  249.  
  250.  
  251. /***************************************/
  252. /************** DoEvent.c **************/
  253. /***************************************/
  254.  
  255.  
  256.  
  257. void            DoEvent(EventRecord *event);
  258.  
  259.  
  260. void            DoActivate(WindowPtr window);
  261.     /*
  262.     ** •••••    CALLED BY FRAMEWORK
  263.     **
  264.     ** INPUT:    window        This is the window being activated or deactivated.
  265.     **
  266.     ** The application framework calls this application function when a window needs
  267.     ** activation or deactivation.  Note that this may happen at times other than
  268.     ** event handling.  For example:  If you call HiliteWindows, if some windows are
  269.     ** found with the wrong hilite value, they will be hilited or unhilited, and 
  270.     ** DoActivate will be called to give the application a chance to do whatever
  271.     ** else is appropriate for activation or deactivation of the window. */
  272.  
  273.  
  274.  
  275. void            DoCursor(void);
  276.     /*
  277.     ** •••••    CALLED BY FRAMEWORK
  278.     **
  279.     ** The application framework calls this application function when the cursor
  280.     ** needs updating.  The application does whatever is appropriate, which in many cases
  281.     ** is simply to call the framework function DoWindowCursor.  See DoWindowCursor
  282.     ** for more information. */
  283.  
  284.  
  285.  
  286. /************************************/
  287. /************** File.c **************/
  288. /************************************/
  289.  
  290.  
  291.  
  292. OSErr            InitDocument(FileRecHndl frHndl);
  293.     /*
  294.     ** •••••    CALLED BY FRAMEWORK
  295.     **
  296.     ** INPUT:    frHndl        The file (document) reference handle.
  297.     ** RESULT:    OSErr
  298.     **
  299.     ** The application framework calls this application function when a file reference
  300.     ** handle needs to be further initialized.  The frHndl has already been initialized
  301.     ** with default values.  This is the application's chance to change these values
  302.     ** before the window is created for the document (if one is to be created), and also
  303.     ** if this was called by OpenDocument, then the document will also be read.  This is
  304.     ** the application's chance to change the file read/write procs so that if there is a
  305.     ** custom file format, the correct read/write routines will be called for this
  306.     ** document. */
  307.  
  308.  
  309.  
  310. long            InitDocumentSize(OSType sftype);
  311.     /*
  312.     ** •••••    CALLED BY FRAMEWORK
  313.     **
  314.     ** INPUT:    sftype        The OSType of the document about to be created.
  315.     ** RESULT:    long        The size that the file reference handle should be created.
  316.     **
  317.     ** The application framework calls this application function when it is about to
  318.     ** create a file reference handle.  The framework needs to know how big to create the
  319.     ** handle.  Your application may wish to store additional fields in the frHndl, and so
  320.     ** therefore it may be a different size than usual.  See the various sample
  321.     ** applications for a sample of this function (in the source file File.c).  Note that
  322.     ** for the ViewHierarchy debugging window, a different size is returned. */
  323.  
  324.  
  325.  
  326. /*************************************/
  327. /************** File2.c **************/
  328. /*************************************/
  329.  
  330.  
  331.  
  332. OSErr            DefaultInitDocument(FileRecHndl frHndl, short version,
  333.                                     short numUndos, short numSaveUndos);
  334.     /*
  335.     ** INPUT:    frHndl            Recently created (most likely by the framework) file
  336.     **                            reference handle.
  337.     **            version            Version number to store into the document.
  338.     **             numUndos        The number of undos to be managed by the hierarchical
  339.     **                            document architecture.
  340.     **            numSaveUndos    The number of undos to be saved with the document
  341.     **                            (commonly none, so 0).
  342.     ** RESULT:    OSErr
  343.     **
  344.     ** This function does the standard document initialization.  The standard document
  345.     ** uses the hierarchical document package TreeObj.  Read the TreeObj documentation for
  346.     ** more information. */
  347.  
  348.  
  349.  
  350. OSErr            DisposeDocument(FileRecHndl frHndl);
  351.     /*
  352.     ** INPUT:    frHndl        The file reference being disposed of.
  353.     ** RESULT:    OSErr
  354.     **
  355.     ** This function is automatically called by such functions as DisposeOneWindow.  It
  356.     ** calls the designated free document procedure, which by default is FreeDocument.
  357.     ** The free document procedure is responsible for disposing of any and all handles
  358.     ** that were created by the init document procedure. */
  359.  
  360.  
  361.  
  362. OSErr            NewDocument(FileRecHndl *returnHndl, OSType sftype, Boolean incTitleNum);
  363.     /*
  364.     ** INPUT:    sftype            The OSType of the desired document.
  365.     **            incTitleNum        Pass in true if you want the document number which is
  366.     **                            (optionally) appended to the title incremented.
  367.     ** OUTPUT:    returnHndl        The frHndl created is returned here.
  368.     **                            Note that there are two special cases that you can call
  369.     **                            this function.  The purpose for both is to change
  370.     **                            the untitledCount value.  If you pass in an sftype of 0,
  371.     **                            then the frHndl value is used as an indicator as to what
  372.     **                            to do with the untitledCount value.  If you pass in 0
  373.     **                            for the frHndl value, untitledCount is reset to 0.
  374.     **                            If you pass in a -1, untitledCount is decremented.
  375.     ** RESULT:    OSErr            If an error is returned, then there is no returnHndl.
  376.     **
  377.     ** This function is called by the application, directly or indirectly.  Even if you
  378.     ** have used the application editor to set up AppWannabe to automatically open
  379.     ** document windows (file-based or not), this gets called.
  380.     **
  381.     ** NewDocument first calls the application function InitDocumentSize to allow the
  382.     ** application to declare how large the file reference handle should be.  It then
  383.     ** creates the frHndl based on the return value of InitDocumentSize
  384.     ** (via NewHandleClear), and then initializes the fields to their default values.
  385.     **
  386.     ** NewDocument then calls another application function called InitDocument.  The
  387.     ** purpose of this application function is to change any of the defaults that aren't
  388.     ** appropriate for the document.
  389.     **
  390.     ** Note that the typical way to create document with AppsToGo (because it is the
  391.     ** easiest) is to create them with the application editor.  NewDocument, for backwards
  392.     ** compatibility notes if there is an AppsToGo application editor entry for this
  393.     ** OSType.  If so, then there is a lot more information directly available for this
  394.     ** document.  If the document being created was described with the editor, then read
  395.     ** part 1 below.  If you are calling NewDocument directly without having described
  396.     ** this OSType with the AppsToGo application editor, then read part 2 below.
  397.     ** (The part 2 technique is really only for backwards compatibility.)
  398.     **
  399.     ** PART 1:    The document title is entered in the AppsToGo editor.  If there is no
  400.     **            title entered there, or if the title starts with a space, then no default
  401.     **            title is placed in the document reference.  (When a window is created, if
  402.     **            there is no document name, then the 'WIND' resource title is used as-is
  403.     **            instead.)
  404.     **
  405.     **            If true is passed in for incTitleNum, then if a valid title was entered in
  406.     **            the AppsToGo editor, then untitledCount is incremented, and then appended
  407.     **            to the title.
  408.     **
  409.     ** PART 2:    New documents will be created with a default title.  This title is created
  410.     **            by appending a number to the corresponding STR# individual string.  The
  411.     **            STR# resource ID #259 holds the default text for the window titles.  Which
  412.     **            string number is determined by the OSType array gTypeList.  gTypeList
  413.     **            contains all of the file types that can be opened by the application.  The
  414.     **            list is walked, and the location in the gTypeList array that holds the
  415.     **            correct file type is used as an index into the STR# resource.  If the file
  416.     **            type isn’t found in the list, then the first string in the STR# resource
  417.     **            is used.
  418.     **
  419.     **            The next greatest integer is appended to the end of the individual string
  420.     **            selected for the document.  If incTitleNum is true, then the global
  421.     **            integer is first incremented prior to appending the number.
  422.     **
  423.     **            If you want to create a document with the title found in the 'WIND'
  424.     **            resource, first call NewDocument().  After you have the frHndl for the
  425.     **            document, set the file name in the (*frHndl)->fileState.fss.name field to
  426.     **            an empty string.  When the window is opened for this document, if this
  427.     **            name is an empty string, it titles the window according to what is found
  428.     **            in the 'WIND' resource for that window.  If this field is not an empty
  429.     **            string, then the 'WIND' title is overridden, and the file name is used. */
  430.  
  431.  
  432.  
  433. OSErr            OpenDocument(FileRecHndl *result, FSSpecPtr fileToOpen, char permission);
  434.     /*
  435.     ** INPUT:    fileToOpen        A pointer to the FSSpec for the file to open, or nil if
  436.     **                            the user should determine via StandardFile.
  437.     **                            Also, if you want to open a movie, pass in kOpenMovie for
  438.     **                            the FSSpec pointer.
  439.     **            permission        As you would expect -- fsRdPerm or fsRdWrPerm.
  440.     ** RESULT:    OSErr
  441.     **
  442.     ** This function does the human-interface thing for opening a document.  It
  443.     ** also calls NewDocument() to initialize a document.  To actually read in
  444.     ** the data, OpenDocument() calls the designated read document procedure, which by
  445.     ** default is ReadDocument().  The read document procedure is responsible for reading
  446.     ** the document data into ram in association with the FileRecHndl created by
  447.     ** NewDocument(). */
  448.  
  449.  
  450.  
  451. OSErr            SaveDocument(FileRecHndl frHndl, WindowPtr window, short saveMode);
  452.     /*
  453.     ** INPUT:    frHndl
  454.     **            window
  455.     **            saveMode    The mode for saving -- kSave, kSaveAs, kClose, kQuit
  456.     ** RESULT:    OSErr
  457.     **
  458.     ** This function does the human-interface thing for saving a document.  The
  459.     ** human-interface presented to the user is determined by the saveMode.
  460.     **
  461.     ** To actually write out the data, SaveDocument calls the designated write document
  462.     ** procedure, which by default is WriteDocument.  The write document procedure is
  463.     ** responsible for writing the document data to the designated file. */
  464.  
  465.  
  466.  
  467. void            ConvertOldToNewSFReply(SFReply *oldReply, StandardFileReply *newReply);
  468.     /*
  469.     ** INPUT:    oldReply
  470.     ** OUTPUT:    newReply
  471.     **
  472.     ** When running on a pre-7.0 system, SFGetFile or SFPutFile is called.  Then
  473.     ** ConvertOldToNewSFReply is called to convert the reply record to the new
  474.     ** format.  This allows the rest of the application to use only a single
  475.     ** record format. */
  476.  
  477.  
  478.  
  479. Boolean            DisplayGetFile(StandardFileReply *reply, short typeListLen,
  480.                                SFTypeList typeList);
  481.     /*
  482.     ** INPUT:    typeListLen        Length of typeList.
  483.     **            typeList        List of acceptable OSTypes to be displayed by
  484.     **                            StandardFile.
  485.     ** OUTPUT:    reply            Reply record -- result of StandardFile.
  486.     ** RESULT:    Boolean            Returns true if reply is good.
  487.     **
  488.     ** Simple routine to display a list of files with our file type, independent of
  489.     ** system (6 or 7). */
  490.  
  491.  
  492.  
  493. Boolean            DisplayPutFile(StandardFileReply *reply);
  494.     /*
  495.     ** IN/OUT:    reply            Reply record for standard file.
  496.     ** RESULT:    Boolean            Returns true if reply is good.
  497.     **
  498.     ** Displays the StandardFile PutFile dialog box. Fills out the passed reply
  499.     ** record, and returns the sfGood field as a result. */
  500.  
  501.  
  502.  
  503. OSErr            UseDocResFile(FileRecHndl frHndl, short *oldRes, char perm);
  504.     /*
  505.     ** INPUT:    frHndl
  506.     **            perm
  507.     ** OUTPUT:    oldRes
  508.     ** RESULT:    OSErr
  509.     **
  510.     ** Use the resource fork for the designated document file.  This function
  511.     ** also returns the old CurResFile, so you can set it back when you are done.
  512.     ** Simply call this function, whether or not you have a resource fork.  If
  513.     ** there isn’t a resource fork, then one will be created.  If there is one,
  514.     ** but it isn’t open yet, it will be opened.  If it is already opened, it
  515.     ** sets it as the current resource fork.  What more do you want? */
  516.  
  517.  
  518.  
  519. OSErr            CloseDocResFile(FileRecHndl frHndl);
  520.     /*
  521.     ** INPUT:    frHndl
  522.     ** RESULT:    OSErr
  523.     **
  524.     ** If there is a resource fork opened for this document (via UseDocResFile),
  525.     ** this closes it. */
  526.  
  527.  
  528.  
  529. long            GetModNum(void);
  530.     /*
  531.     ** Get the modification number for the document.  TreeObj automatically
  532.     ** increments this. */
  533.  
  534.  
  535.  
  536. Boolean            GetDocDirty(FileRecHndl frHndl);
  537.     /*
  538.     ** INPUT:    frHndl
  539.     **
  540.     ** Get the dirty state of the document. */
  541.  
  542.  
  543.  
  544. Boolean            GetWindowDirty(WindowPtr window);
  545.     /*
  546.     ** INPUT:    window
  547.     **
  548.     ** Given a window, return the dirty state of the associated document. */
  549.  
  550.  
  551.  
  552. void            SetDocDirty(FileRecHndl frHndl);
  553.     /*
  554.     ** INPUT:    frHndl
  555.     **
  556.     ** Set the document dirty. */
  557.  
  558.  
  559.  
  560. void            SetWindowDirty(WindowPtr window);
  561.     /*
  562.     ** INPUT:    window
  563.     **
  564.     ** Given a window, set the associated document as dirty. */
  565.  
  566.  
  567.  
  568. OSErr            SetDefault(short newVRefNum,  long newDirID,
  569.                            short *oldVRefNum, long *oldDirID);
  570.     /*
  571.     ** INPUT:    newVRefNum
  572.     **            newDirID
  573.     ** OUTPUT:    oldVRefNum
  574.     **            oldDirID
  575.     ** RESULT:    OSErr
  576.     **
  577.     ** The SetDefault function sets the default volume and directory to the volume
  578.     ** specified by newVRefNum and the directory specified by newDirID. The current
  579.     ** default volume and directory are returned in oldVRefNum and oldDir and should be
  580.     ** used to restore things to their previous condition *as soon as possible* with the
  581.     ** RestoreDefault function. These two functions are designed to be used as a wrapper
  582.     ** around Standard C I/O routines where the location of the file is implied to be the
  583.     ** default volume and directory. In other words, this is how you should use these
  584.     ** functions:
  585.     **
  586.     **        err = SetDefault(newVRefNum, newDirID, &oldVRefNum, &oldDirID);
  587.     **        if (!err)
  588.     **            {
  589.     **                -- call the Stdio functions like remove, rename, tmpfile, fopen,   --
  590.     **                -- freopen, etc. or non-ANSI extentions like fdopen, fsetfileinfo, --
  591.     **                -- create, open, unlink, etc. here!                                   --
  592.     **
  593.     **                err = RestoreDefault(oldVRefNum, oldDirID);
  594.     **            }
  595.     **
  596.     ** By using these functions as a wrapper, you won't need to open a working directory
  597.     ** (because they use HSetVol) and you won't have to worry about the effects of using
  598.     ** HSetVol (documented in Technical Note #140: Why PBHSetVol is Dangerous 
  599.     ** and in the Inside Macintosh: Files book in the description of the HSetVol and 
  600.     ** PBHSetVol functions) because the default volume/directory is restored before 
  601.     ** giving up control to code that might be affected by HSetVol.
  602.     ** Use this and the below call instead of the old-style FSpSetWD and FSpResetWD. */
  603.  
  604.  
  605.  
  606. OSErr            RestoreDefault(short oldVRefNum, long oldDirID);
  607.     /*
  608.     ** INPUT:    oldVRefNum
  609.     **            oldDirID
  610.     ** RESULT:    OSErr
  611.     **
  612.     ** Resets the default directory to what it was prior to calling SetDefault. */
  613.  
  614.  
  615.  
  616. OSErr            GetFileLocation(short refNum, short *vRefNum, long *dirID,
  617.                                 StringPtr fileName);
  618.     /*
  619.     ** INPUT:    refNum
  620.     ** OUTPUT:    vRefNum
  621.     **            dirID
  622.     **            fileName
  623.     ** RESULT:    OSErr
  624.     **
  625.     ** Get the vRefNum, dirID, and fileName of a file.
  626.     ** (vRefNum and dirID are its location). */
  627.  
  628.  
  629.  
  630. OSErr            CurResOnly(Handle *hndl);
  631.     /*
  632.     ** IN/OUT:    hndl
  633.     ** RESULT:    OSErr
  634.     **
  635.     ** After getting a resource, you can't actually be sure that it came from the current
  636.     ** resource file.  Even if you make a call such as Get1Resource, starting with
  637.     ** system 7.1, you can't really be sure that it came from the current resource file.
  638.     ** (The resource files may be overridden, or they may be flagged to be extended, as is
  639.     ** the case with font files.)  This checks to see that the resource actually came from
  640.     ** the current resource file.  If it didn't, then the handle returned is nil, and the
  641.     ** error returned is resNotFound.  (You probably don't need this function unless you
  642.     ** are doing some kind of resource-editing function.) */
  643.  
  644.  
  645.  
  646. /************************************/
  647. /************** Init.c **************/
  648. /************************************/
  649.  
  650.  
  651.  
  652. void            Initialize(short moreMasters, long minHeap, long minSpace,
  653.                            ProcPtr init1, ProcPtr init2);
  654.     /*
  655.     ** INPUT:    moreMasters
  656.     **            minHeap
  657.     **            minSpace
  658.     **            init1
  659.     **            init2
  660.     **
  661.     ** Given minHeap and minSpace values, get stuff going.  Also, we are passed
  662.     ** in two procedure pointers.  If these are not nil, they are called at
  663.     ** intermediate points during the initialization process.  The first proc
  664.     ** is called after the Utilities.c standard initialization is complete.  The
  665.     ** second proc is called very near the end of the initialization, but just
  666.     ** prior to the menus being initialized. */
  667.  
  668.  
  669.  
  670. void            StartDocuments(void);
  671.     /*
  672.     ** This function handles the documents selected in the finder, either for
  673.     ** loading or for printing.  This is only if we don't have AppleEvents.
  674.     ** If we have AppleEvents, then this will all be done automatically via
  675.     ** those wonderful AppleEvent thingies. */
  676.  
  677.  
  678.  
  679. /****************************************/
  680. /************** GWLayers.c **************/
  681. /****************************************/
  682.  
  683.  
  684.  
  685. #ifndef         __GWLAYERS__
  686. #include        "GWLayers.h"
  687. #endif
  688.  
  689.  
  690.  
  691. /*******************************************/
  692. /************** ListControl.c **************/
  693. /*******************************************/
  694.  
  695.  
  696.  
  697. #ifndef         __LISTCONTROL__
  698. #include        "ListControl.h"
  699. #endif
  700.  
  701.  
  702.  
  703. /************************************/
  704. /************** Menu.c **************/
  705. /************************************/
  706.  
  707.  
  708.  
  709. void            DoAdjustMenus(void);
  710.     /*
  711.     ** •••••    CALLED BY FRAMEWORK
  712.     **
  713.     ** The application framework calls this application function when menus need
  714.     ** adjusting.  The application then handles activation and deactivation of the
  715.     ** menus.  This probably means simply calling the framework function
  716.     ** DoAdjustMBARMenus.  See DoAdjustMBARMenus for more information, or look at the
  717.     ** sample application AppWannabe for a sample usage. */
  718.  
  719.  
  720.  
  721. Boolean            DoMenuCommand(short menuID, short menuItem);
  722.     /*
  723.     ** •••••    CALLED BY FRAMEWORK
  724.     **
  725.     ** INPUT:    menuID
  726.     **            menuItem
  727.     **
  728.     ** The application framework calls this application function when a menu
  729.     ** command has been received and it needs to be handled.  Note that the menuItem
  730.     ** has already been converted to a "soft" menuItem if you have a STR# hard <-> soft
  731.     ** menuItem mapping resource of the same resource ID as the menu.
  732.     ** See the document "=AppsToGo Manual" for more info. */
  733.  
  734.  
  735.  
  736. /*******************************************/
  737. /************** PICTControl.c **************/
  738. /*******************************************/
  739.  
  740.  
  741.  
  742. #ifndef         __PICTCONTROL__
  743. #include        "PICTControl.h"
  744. #endif
  745.  
  746.  
  747.  
  748. /***********************************/
  749. /************** PPC.c **************/
  750. /***********************************/
  751.  
  752.  
  753.  
  754. #ifndef         __PPC__
  755. #include        "PPC.h"
  756. #endif
  757.  
  758.  
  759.  
  760. /*************************************/
  761. /************** Print.c **************/
  762. /*************************************/
  763.  
  764.  
  765.  
  766. OSErr            PrintDocument(FileRecHndl frHndl, Boolean jobDlg, Boolean firstJob);
  767.     /*
  768.     ** INPUT:    frHndl
  769.     **            jobDlg
  770.     **            firstJob
  771.     ** RESULT:    OSErr
  772.     **
  773.     ** This print-loop function is designed to be called under various situations.
  774.     ** The big issue that it handles is finder printing.  If multiple documents
  775.     ** are to be printed from the finder, the user should only see one job dialog
  776.     ** for all the files.  (If a job dialog is shown for each file, how does the
  777.     ** user know for which file the dialog is for?)  So, for situations where
  778.     ** there is more than one file to be printed, call this code the first time
  779.     ** with the firstJob boolean true.  Normally, the jobDlg boolean will also
  780.     ** be true, except that under 7.0, you may be printing in the background.
  781.     ** If this is the case, you don't want a job dialog for even the first file,
  782.     ** and you should pass in false for the jobDlg boolean in this case.  For
  783.     ** files 2-N, you should pass false for both booleans.  For regular application
  784.     ** printing, you should pass true for both booleans, since the file is the
  785.     ** first (only) file, and you are not in the background.
  786.     **
  787.     ** After calling this function to print a document, you need to call it
  788.     ** again with a nil document handle.  The print record for the first (or only)
  789.     ** document printed is preserved in a static variable.  This is so that the
  790.     ** job dialog information can be passed on to documents 2-N in the print job.
  791.     ** Calling this function with the document handle nil tells this function
  792.     ** that you are done printing documents, and that the print record for the
  793.     ** first job can be disposed of. */
  794.  
  795.  
  796.  
  797. void            DonePrinting(void);
  798.     /*
  799.     ** DonePrinting makes sure that PrintDocument gets rid of the prMergeHndl
  800.     ** print record that is used for multiple document printing.  Call this
  801.     ** after the last document is printed, or you get a memory leak. */
  802.  
  803.  
  804.  
  805. OSErr            PresentStyleDialog(FileRecHndl frHndl);
  806.     /*
  807.     ** RESULT:    OSErr
  808.     **
  809.     ** Call this from the application to present a style dialog.  The changes are
  810.     ** automatically saved in the document. */
  811.  
  812.  
  813.  
  814. /*******************************************/
  815. /************** System6Help.c **************/
  816. /*******************************************/
  817.  
  818.  
  819.  
  820. OSErr            HelpInitDocument(FileRecHndl frHndl);
  821.     /*
  822.     ** INPUT:    frHndl
  823.     ** RESULT:    OSErr
  824.     **
  825.     ** If you want balloon help support for system 6, and you've added a '6hlp'
  826.     ** OSType into your application with the AppsToGo editor, then in the
  827.     ** File.c function InitDocument in your application, call HelpInitDocument
  828.     ** to instantiate the help code.  (See AppWannabe for a sample usage.)
  829.  
  830.  
  831.  
  832. /***********************************************/
  833. /************** TextEditControl.c **************/
  834. /***********************************************/
  835.  
  836.  
  837.  
  838. #ifndef         __TEXTEDITCONTROL__
  839. #include        "TextEditControl.h"
  840. #endif
  841.  
  842.  
  843.  
  844. /***************************************/
  845. /************** TreeObj.c **************/
  846. /***************************************/
  847.  
  848.  
  849.  
  850. #ifndef         __TREEOBJ__
  851. #include        "TreeObj.h"
  852. #endif
  853.  
  854.  
  855.  
  856. /*********************************************/
  857. /************** ViewHierarchy.c **************/
  858. /*********************************************/
  859.  
  860.  
  861.  
  862. OSErr            VHInitDocument(FileRecHndl frHndl);
  863. long            VHFileTypeSize(void);
  864. void            VHRootInfo(TreeObjHndl root, char *cptr);
  865. void            VHFileRecInfo(TreeObjHndl root, char *cptr);
  866.     /* These functions are in the framework to support the View Hierarchy debugging window.
  867.     ** The sample application AppWannabe has these calls in it.  They can be conditionally
  868.     ** removed by setting the compile variable VH_VERSION to 0.  You should never have to
  869.     ** call them directly, so therefore I didn't bother documenting them. */
  870.  
  871.  
  872.  
  873. /***************************************/
  874. /************** Window2.c **************/
  875. /***************************************/
  876.  
  877.  
  878. OSErr            DoNewWindow(FileRecHndl frHndl, WindowPtr *retWindow,
  879.                             WindowPtr relatedWindow, WindowPtr behind);
  880.     /*
  881.     ** INPUT:    frHndl            This file reference is used to create a window.  At this
  882.     **                            point there is (or should be) window creation information
  883.     **                            in the file reference.  If you are using the AppsToGo
  884.     **                            application editor to create your documents, then the
  885.     **                            information is in the file reference at this point.
  886.     **            relatedWindow    This window is what is used to determine which monitor
  887.     **                            the window should be created on.  If there is a related
  888.     **                            window passed in, DoNewWindow determines which monitor
  889.     **                            holds most of the window.  That monitor is then the
  890.     **                            target monitor for the new window.
  891.     **            behind            This window is the window that the new window is created
  892.     **                            behind.  Pass in -1 if the window is to be created as
  893.     **                            the frontmost window.  Pass in 0 if it is to be created
  894.     **                            as the backmost window.
  895.     ** OUTPUT:    retWindow        Return the created window here.  If you don't care to
  896.     **                            know, then pass in nil.
  897.     ** RESULT:    OSErr            If an error is returned, then no window was created.
  898.     **
  899.     ** This function is called by the application or framework at appropriate times to
  900.     ** give a document a window.  To create a document window, first a document is created
  901.     ** by the application via NewDocument or OpenDocument.  If this succeeds then the
  902.     ** application needs to create a window for the document.  To do this, the application
  903.     ** calls DoNewWindow.  DoNewWindow calls the content initialization procedure, which
  904.     ** by default is InitContent.  If you want a different content initialization
  905.     ** procedure, replace the default procedure pointer initContentProc with your own.
  906.     ** Normally however, you will just place your own content initialization procedure in
  907.     ** the function InitContent.  It is possible though that your application has more
  908.     ** than one document type and window type.  If this is the case, then you may very
  909.     ** well want an alternate content initialization procedure.  If you do, you will want
  910.     ** to replace the default procedure pointer after the NewDocument or OpenDocument
  911.     ** call and before the call to DoNewWindow.  (You may place the code for replacing the
  912.     ** content initialization procedure and imaging procedure in the function InitDocument.
  913.     ** The defaults are already established at that point.  You would just replace them
  914.     ** with the alternates. */
  915.  
  916.  
  917.  
  918. void            NewWindowTitle(WindowPtr window, StringPtr altTitle);
  919.     /*
  920.     ** INPUT:    window
  921.     **            altTitle
  922.     **
  923.     ** Call this function if you want to change the title of the window.
  924.     ** If you pass in nil, the window title will be gotten from the FSSpec of the
  925.     ** document.  If you pass in an alternate title in altTitle, that will be used
  926.     ** instead of the document name. */
  927.  
  928.  
  929.  
  930. Boolean            DisposeAllWindows(void);
  931.     /*
  932.     ** This function interates through all of the windows and calls DisposeOneWindow
  933.     ** on each one.  If DisposeOneWindow returns that the user canceled the closing
  934.     ** of a window that needed saving, then DisposeAllWindows also aborts.  This
  935.     ** is used when an application is quitting. */
  936.  
  937.  
  938.  
  939. Boolean            DisposeOneWindow(WindowPtr window, short saveMode);
  940.     /*
  941.     ** INPUT:    window
  942.     **            saveMode
  943.     **
  944.     ** This function does exactly as you would expect.  The saveMode indicates
  945.     ** whether the window is being closed due to a close request, or due to the
  946.     ** application being quit.  If true is returned, then disposing of the window
  947.     ** was successful.  If false is returned, the user may have canceled the close
  948.     ** due to the document needing to be saved, a dialog as such popping up, and
  949.     ** the user clicking cancel. */
  950.  
  951.  
  952.  
  953. WindowPtr        SetFilePort(FileRecHndl frHndl);
  954.     /*
  955.     ** INPUT:    frHndl
  956.     **
  957.     ** This function sets the current port for the designated file.  It also returns
  958.     ** the old port so that the port can be restored, if so desired. */
  959.  
  960.  
  961.  
  962. void            DoResizeWindow(WindowPtr window, short oldh, short oldv);
  963.     /*
  964.     ** INPUT:    window
  965.     **            oldh
  966.     **            oldv
  967.     **
  968.     ** This function is called when a window is resized.  This function may need
  969.     ** to know the old size of the window.  The new size is determined by the
  970.     ** dimensions of the window that was resized.  It moves and resizes the
  971.     ** document scrollbars and growIcon (if any) to reflect the new size of
  972.     ** the window.  It then calls the procedure stored in the procPtr field
  973.     ** resizeContentProc, in case there is additional sizing necessary for the window.
  974.     ** The default resizeContentProc is ResizeContent.  If you wish an alternate
  975.     ** resizeContentProc, then you can replace the default in the function
  976.     ** InitDocument, as the default is already established at this point. */
  977.  
  978.  
  979.  
  980. void            GetWindowChange(WindowPtr window, short oldh, short oldv,
  981.                                 short *dx, short *dy);
  982.     /*
  983.     ** INPUT:    window
  984.     **            oldh
  985.     **            oldv
  986.     ** OUTPUT:    dx
  987.     **            dy
  988.     **
  989.     ** This function returns the difference between the old window size and the new window
  990.     ** size.  Pass in the old window size, and this function looks up the current size,
  991.     ** gets the difference, and returns it. */
  992.  
  993.  
  994.  
  995. void            DoUpdateSeparate(WindowPtr window, RgnHandle *contRgn,
  996.                                  RgnHandle *frameRgn);
  997.     /*
  998.     ** INPUT:    window
  999.     ** OUTPUT:    contRgn
  1000.     **            frameRgn
  1001.     **
  1002.     ** This function separates the update region into two portions.  One portion is
  1003.     ** the frame area, which consists of document scrollbars and growIcon (if any), plus
  1004.     ** an optional application-defined frame area.  The other portion is the rest of the
  1005.     ** window content that needs updating.  This separation is so that the document
  1006.     ** scrollbars can be updated first, and then this area can be clipped out of the rest
  1007.     ** of the updating so that the window content doesn’t draw over the document
  1008.     ** scrollbars and growIcon.  The clipping is managed with just the visRgn.  This frees
  1009.     ** up the clipRgn for application specific clipping.  Note that if either region
  1010.     ** is computed to be empty, DoUpdateSeparate will return a nil for that handle. */
  1011.  
  1012.  
  1013.  
  1014. void            BeginContent(WindowPtr window);
  1015.     /*
  1016.     ** INPUT:    window
  1017.     **
  1018.     ** This function clips out the document scrollbars and growIcon from the updatable
  1019.     ** area.  It also sets the origin of the port to the current document scrollbar
  1020.     ** values.  BeginContent must be balanced by a call to EndContent.  BeginContent calls
  1021.     ** BeginUpdate, and BeginUpdate calls can’t be nested.  Due to this, BeginContent has
  1022.     ** a usage counter, which prevents nested calls to BeginUpdate.  BeginContent clips
  1023.     ** out the document scrollbar and growIcon area without involving the clipRgn so that
  1024.     ** the application is free to use the clipRgn as it sees fit.  The only caveat is that
  1025.     ** you can not modify the updateRgn between the BeginContent and EndContent calls, as
  1026.     ** anything contributed to the updateRgn between these calls will be lost.  If you
  1027.     ** need to do this, accumulate the areas in a separate region, call EndContent, and
  1028.     ** then call InvalRgn. */
  1029.  
  1030.  
  1031.  
  1032. void            EndContent(WindowPtr window);
  1033.     /*
  1034.     ** INPUT:    window
  1035.     **
  1036.     ** Calls to BeginContent must be balanced.  They also don’t nest.  EndContent undoes
  1037.     ** the clipping of the frame area that BeginContent invoked. */
  1038.  
  1039.  
  1040.  
  1041. void            BeginFrame(WindowPtr window);
  1042.     /*
  1043.     ** INPUT:    window
  1044.     **
  1045.     ** This function does the same thing as BeginContent, except that it clips out
  1046.     ** everything except the frame area.  The frame area consists of the sidebars and any
  1047.     ** additional application-defined frame area.  The application-defined frame area is
  1048.     ** defined in the application function CalcFrameArea().  Also, the origin is set to
  1049.     ** -16384,0, which is the coordinate space for sidebar controls created with the
  1050.     ** AppsToGo application editor. */
  1051.  
  1052.  
  1053.  
  1054. void            EndFrame(WindowPtr window);
  1055.     /*
  1056.     ** INPUT:    window
  1057.     **
  1058.     ** Calls to BeginFrame must be balanced.  They also don’t nest.  EndFrame undoes the
  1059.     ** clipping of the frame area that BeginFrame invoked. */
  1060.  
  1061.  
  1062.  
  1063. void            AdjustScrollBars(WindowPtr window);
  1064.     /*
  1065.     ** INPUT:    window
  1066.     **
  1067.     ** You call this function whenever you need the scrollbars to reflect the window
  1068.     ** state and position.  If you change the sidebar sizes or indent sizes by hand,
  1069.     ** you will need to call this.  Generally an application will not have to call this
  1070.     ** directly, as there are functions for scrolling, setting sidebar sizes, indent
  1071.     ** sizes, etc. */
  1072.  
  1073.  
  1074.  
  1075. void            GetContentOrigin(WindowPtr window, Point *contOrg);
  1076.     /*
  1077.     ** INPUT:    window
  1078.     ** OUTPUT:    contOrg
  1079.     **
  1080.     ** This function returns the origin of the content of the window.  The value
  1081.     ** is gotten from the current value of the document scrollbars.  If a scrollbar
  1082.     ** is missing, the control value for that scrollbar is assumed to be 0.  Note that
  1083.     ** if you have sidebars in your document, the origin value has the sidebar value
  1084.     ** subtracted.  For example:  You have a top sidebar of 32 pixels, and the vertical
  1085.     ** scrollbar has a control value of 0.  This will return you a vertical origin
  1086.     ** of -32. */
  1087.  
  1088.  
  1089.  
  1090. void            SetContentOrigin(WindowPtr window, long newh, long newv);
  1091.     /*
  1092.     ** INPUT:    window
  1093.     **            newh
  1094.     **            newv
  1095.     **
  1096.     ** This function allows you to change the value of the document scrollbars,
  1097.     ** and by doing this, the document is scrolled to reflect the change, and
  1098.     ** an update event is generated for the document scroll.  Note that if you are
  1099.     ** using sidebars, you will have to subtract the value of the sidebar to get
  1100.     ** the expected results (see GetContentOrigin).  Also note that this function accepts
  1101.     ** long values.  You may have a proc for handling longs for the document scrollbars.
  1102.     ** The proc is stored in the refCon of the document scrollbars.  If the refCon
  1103.     ** value of the document scrollbars is 0, then it is assumed that values from 0
  1104.     ** to 32767 are adequate for document scrolling. */
  1105.  
  1106.  
  1107.  
  1108. void            GetContentRect(WindowPtr window, Rect *contRct);
  1109.     /*
  1110.     ** INPUT:    window
  1111.     ** OUTPUT:    contRct
  1112.     **
  1113.     ** This function returns a rectangle that represents the content area of the
  1114.     ** window less the scrollbar and sidebar areas. */
  1115.  
  1116.  
  1117.  
  1118. void            SetDocSize(FileRecHndl frHndl, long hSize, long vSize);
  1119.     /*
  1120.     ** INPUT:    frHndl
  1121.     **            hSize
  1122.     **            vSize
  1123.     **
  1124.     ** This function sets the document size to the new designated size.  It also
  1125.     ** makes appropriate adjustments to the scrollbars to reflect the new size. */
  1126.  
  1127.  
  1128.  
  1129. void            SetSidebarSize(FileRecHndl frHndl, short newLeft, short newTop);
  1130.     /*
  1131.     ** INPUT:    frHndl
  1132.     **            newLeft
  1133.     **            newTop
  1134.     **
  1135.     ** This function is used to set the size of the sidebars.  This is particularly
  1136.     ** useful for being able to show and hide a tool palette, or if you are using
  1137.     ** OCE and want to show a mailer at the top of your window.  The sidebar value
  1138.     ** should initially be set in File.c, along with other document initialization.
  1139.     ** If you wish to change only one of the two sidebar sizes, send in a value of
  1140.     ** kwNoChange for the one that is not to change. */
  1141.  
  1142.  
  1143.  
  1144. void            SetScrollIndentSize(FileRecHndl frHndl, short newh, short newv);
  1145.     /*
  1146.     ** INPUT:    frHndl
  1147.     **            newh
  1148.     **            newv
  1149.     **
  1150.     ** This function is used to set the size of the scrollbar indention.  The scrollbar
  1151.     ** indentnion allows you to put status information or document display related
  1152.     ** tool icons in line with the scrollbar.  They are considered part of the frame,
  1153.     ** as document scrollbars, the grow icon, and sidebars are.  The scrollbar indent
  1154.     ** value should initially be set in File.c, in the same fashion as sidebar values
  1155.     ** are set.  If you wish to change only one of the two scrollbar indent, send in a
  1156.     ** value of kwNoChange for the one that is not to change. */
  1157.  
  1158.  
  1159.  
  1160. FileRecHndl        GetNextDocument(WindowPtr window, OSType sftype);
  1161.     /*
  1162.     ** INPUT:    window
  1163.     **            sftype
  1164.     ** RESULT:    frHndl
  1165.     **
  1166.     ** This function returns the file reference for the next application window
  1167.     ** of the designated kind.  If the window paramater is passed in as nil, it
  1168.     ** finds the top-most window whose document type matches the requested OSType.
  1169.     ** If the window parameter is passed in as non-nil, it returns the next window.
  1170.     ** If there is no next window found, it returns nil.  The sftype parameter
  1171.     ** restricts the finding of a window to a particular type.  If 0 is passed in
  1172.     ** for sftype, then any application window will match. */
  1173.  
  1174.  
  1175.  
  1176. WindowPtr        GetNextWindow(WindowPtr window, OSType sftype);
  1177.     /*
  1178.     ** INPUT:    window
  1179.     **            sftype
  1180.     **
  1181.     ** This function behaves the same as GetNextDocument, but returns a window pointer
  1182.     ** instead of a file reference. */ 
  1183.  
  1184.  
  1185.  
  1186. WindowPtr        GetPreviousWindow(WindowPtr window);
  1187.     /*
  1188.     **INPUT:    window
  1189.     **
  1190.     ** Returns the window in front of the window passed in.  If there is no window
  1191.     ** in front, it returns -1, not nil.  -1 is typically used to indicate the front
  1192.     ** of the window list, whereas nil is used to indicate the back.  This is done to
  1193.     ** stay consistent with the expectations of the toolbox. */
  1194.  
  1195.  
  1196.  
  1197. void            DoZoomWindow(WindowPtr window, EventRecord *event, short zoomDir);
  1198.     /*
  1199.     **INPUT:    window
  1200.     **            event
  1201.     **            zoomDir
  1202.     **
  1203.     ** This function handles zooming of the document window.  It zooms it to the
  1204.     ** current monitor, up to the size of the document data. */
  1205.  
  1206.  
  1207.  
  1208. RgnHandle        DoCalcFrameRgn(WindowPtr window);
  1209.     /*
  1210.     ** INPUT:    window
  1211.     **
  1212.     ** This function calculates the region that encompasses the frame area of the
  1213.     ** document.  The frame area consists of the document scrollbars, growIcon, sidebars,
  1214.     ** and an optional application-defined frame area.  The region is generated in global
  1215.     ** coordinates.  Since the frame region may encompass more than the
  1216.     ** DTS.framework-supported scrollbars and growIcon, a procedure is first called to see
  1217.     ** if there is anything additional in the frame region.  The field calcFrameRgnProc
  1218.     ** holds the procedure pointer that contributes any extra to the frame region.  This
  1219.     ** function is passed an empty region.  If there is no additional contribution to the
  1220.     ** frame region, then the region should be left empty.  Once this procedure is
  1221.     ** returned from, the remaining frame portion is added to this region.  The remaining
  1222.     ** portion would consist of DTS.framework document scrollbars and a growIcon, if there
  1223.     ** are any for this window.  The field calcFrameRgnProc is initialized to the
  1224.     ** default value CalcFrameRgn.  If you wish an alternate drawFrameProc, then you
  1225.     ** can replace the default in the function InitDocument, as the default is
  1226.     ** already established at this point. */
  1227.  
  1228.  
  1229.  
  1230. RgnHandle        DoCalcScrollRgn(WindowPtr window);
  1231.     /*
  1232.     ** INPUT:    window
  1233.     **
  1234.     ** This function calculates the region that encompasses the document scrollbars
  1235.     ** and growIcon (if any).  The region is generated in global coordinates. */
  1236.  
  1237.  
  1238.  
  1239. void            DoContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  1240.     /*
  1241.     ** INPUT:    window
  1242.     **            event
  1243.     **            firstClick
  1244.     **
  1245.     ** This function is called whenever the content portion of a window is clicked in.
  1246.     ** It simply calls the procedure pointer stored in the field contentClickProc.
  1247.     ** The field contentClickProc is initialized to ContentClick.  If you wish
  1248.     ** an alternate contentClickProc, then you can replace the default in the function
  1249.     ** InitDocument, as the default is already established at this point.  The
  1250.     ** boolean firstClick is true if you chose this window to handle first clicks, and
  1251.     ** if the click is actually a first click in the window.  A first click means that
  1252.     ** the window content was clicked on, but the window was not the front window.  The
  1253.     ** window has already been brought to the front, but you may wish the click to also
  1254.     ** be handled as a content click. */
  1255.  
  1256.  
  1257.  
  1258. void            DoDragWindow(WindowPtr window, EventRecord *event, Rect bounds);
  1259.     /*
  1260.     ** INPUT:    window
  1261.     **            event
  1262.     **            bounds
  1263.     **
  1264.     ** This function is used to drag a window.  We can’t use the toolbox function
  1265.     ** DragWindow, as the DTS.framework supports palettes.  Since we are supporting
  1266.     ** palettes, we have to be able to drag a window that isn’t the front, and bring
  1267.     ** it to the front of windows of its kind.  There is no way to coerce DragWindow
  1268.     ** to do this. */
  1269.  
  1270.  
  1271.  
  1272. void            DoDrawFrame(WindowPtr window, Boolean activate);
  1273.     /*
  1274.     ** INPUT:    window
  1275.     **            activate
  1276.     **
  1277.     ** This function may be called when an update event occurs for the window.
  1278.     ** If the update region intersects the frame region (calculated by DoCalcFrameRgn),
  1279.     ** then a frame update occurs and this function is called.  It redraws the
  1280.     ** document scrollbars and growIcon (if any) and then calls the procedure stored
  1281.     ** in the field drawFrameProc, which has a default value of DrawFrame.  If you wish
  1282.     ** an alternate drawFrameProc, then you can replace the default in the function
  1283.     ** InitDocument, as the default is already established at this point. */
  1284.  
  1285.  
  1286.  
  1287. OSErr            DoFreeDocument(FileRecHndl frHndl);
  1288.     /*
  1289.     ** INPUT:    frHndl
  1290.     ** RESULT:    OSErr
  1291.     **
  1292.     ** This is called to generically call the document’s freeing procedure.  This document
  1293.     ** is being disposed of, and any custom memory usage needs to be deallocated.  The
  1294.     ** frHndl itself will be disposed of, but any handle references that it contains
  1295.     ** need to be freed within the document’s freeing procedure.  The default freeing
  1296.     ** procedure is called FreeDocument(). */
  1297.  
  1298.  
  1299.  
  1300. OSErr            DoFreeWindow(FileRecHndl frHndl, WindowPtr window);
  1301.     /*
  1302.     ** INPUT:    frHndl
  1303.     **            window
  1304.     ** RESULT:    OSErr
  1305.     **
  1306.     ** This is called to generically call the document’s window freeing procedure.
  1307.     ** The window is going to be disposed of, and there may be related tasks to disposing
  1308.     ** of the window.  A document may have related windows or views.  This is where you
  1309.     ** would dispose of the related windows.  The default window freeing procedure is
  1310.     ** called FreeWindow(). */
  1311.  
  1312.  
  1313.  
  1314. OSErr            DoImageDocument(FileRecHndl frHndl);
  1315.     /*
  1316.     ** INPUT:    frHndl
  1317.     ** RESULT:    OSErr
  1318.     **
  1319.     ** This function is called whenever the content portion of a window needs to be
  1320.     ** updated or printed.  It simply calls the procedure pointer stored in the field
  1321.     ** imageProc.  The field imageProc is initialized to ImageDocument.  If you wish
  1322.     ** an alternate imageProc, then you can replace the default in the function
  1323.     ** InitDocument, as the default is already established at this point.
  1324.     ** Note that when the document's imageProc is called, only the content can be
  1325.     ** drawn to.  BeginContent() is called prior to calling the imageProc, and
  1326.     ** EndContent() is called upon return. */
  1327.  
  1328.  
  1329.  
  1330. OSErr            DoInitContent(FileRecHndl frHndl, WindowPtr window);
  1331.     /*
  1332.     ** INPUT:    frHndl
  1333.     **            window
  1334.     ** RESULT:    OSErr
  1335.     **
  1336.     ** The window has been created, and is about to be displayed.  At this time, this
  1337.     ** function is called.  It generically calls the window content initialization
  1338.     ** procedure indicated within the frHndl.  The default window content initialization
  1339.     ** procedure is called InitContent(). */
  1340.  
  1341.  
  1342.  
  1343. Boolean            DoKeyDown(EventRecord *event);
  1344.     /* DoKeyDown is first called by the application.  If the key is a menu key, the
  1345.     ** application function DoMenuCommand() is called.  If the key isn’t a menu
  1346.     ** key, DoKeyDown starts walking through the window list, giving each window an
  1347.     ** opportunity to handle the key.  Windows can handle it, eat it, or pass the key
  1348.     ** through to the next window.
  1349.     ** It gives each window a chance to handle the key by calling the key handling
  1350.     ** procedure stored in the frHndl.  The default procedure is called KeyDown().  Here
  1351.     ** are the rules for the window key handling procedure:
  1352.     **
  1353.     ** 1) If it handles the key, it returns true.  This completes the key handling.
  1354.     ** 2) If it doesn’t handle the key, it returns false.  However, there are two
  1355.     **    situations for not handling the key:
  1356.     **      a) The window wants windows behind it to try handling the key.
  1357.     **      b) The window wants nobody else to look at the key.
  1358.     **    This is what the boolean passThrough is for.  If the procedure wishes the next
  1359.     **    window to have a look at the key, it should set the boolean passThrough to true.
  1360.     **    passThrough is already initialized to false prior to calling the procedure,
  1361.     **    which is the common case, so the window key handling procedure only has to
  1362.     **    worry about setting it true.
  1363.     **
  1364.     ** If the window never processes keys and always passes them through to the next
  1365.     ** window, the contentKeyProc field in the frHndl should be set to nil.  This will
  1366.     ** indicate to DoKeyDown() that all keys should be passed through this window.
  1367.     ** DTS.Draw has such a window.  The palette window doesn’t accept keys.  They are
  1368.     ** passed through to document windows that are behind the palette. */
  1369.  
  1370.  
  1371.  
  1372. void            DoMouseDown(EventRecord *event);
  1373.     /*
  1374.     ** INPUT:    event
  1375.     **
  1376.     ** Call this whenever a mouse down event occurs in the application.  Everything is
  1377.     ** handled.  Here’s what DoMouseDown() may do, and what it depends on:
  1378.     ** It handles:
  1379.     **     inContent
  1380.     **     inDrag
  1381.     **     inGoAway
  1382.     **     inGrow
  1383.     **     inMenuBar
  1384.     **     inSysWindow
  1385.     **     inZoomIn
  1386.     **     inZoomOut
  1387.     **
  1388.     ** inContent:
  1389.     **     a) If the window clicked on is a DA window, then bring the window to the front.
  1390.     **     b) If the window is not the top-most of its kind (palette,dialog,document),
  1391.     **        then it is made the top-most of its kind.  If the window has the
  1392.     **        kwDoFirstClick bit set, then DoContentClick is called, indicating that it
  1393.     **        is a first click.
  1394.     **
  1395.     ** inDrag:
  1396.     **     The window is dragged.  When released, if the command key was not held down at
  1397.     **     the time of the click, the window is made the top-most window of its kind.
  1398.     **
  1399.     ** inGoAway:
  1400.     **     The go-away is tracked.  If the document is dirty, then the user is asked if
  1401.     **     the document should first be saved.  The user can save, discard, or cancel.
  1402.     **     All cases are handled.
  1403.     **
  1404.     ** inGrow:
  1405.     **     The window is grown.  Scrollbar adjustments are handled as they are in the
  1406.     **     7.0 finder.
  1407.     **
  1408.     ** inMenuBar:
  1409.     **     MenuSelect() is called, then the application function DoMenuCommand() is called
  1410.     **     with the result of MenuSelect().
  1411.     **
  1412.     ** inSysWindow:
  1413.     **     SystemClick() is called.
  1414.     **
  1415.     ** inZoomIn:
  1416.     ** inZoomOut:
  1417.     **     The window is grown, according to the human-interface guidelines for zooming.
  1418.     **     The window is zoomed on the monitor that contains most of the window.  The zoom
  1419.     **     size is limited by the document size.  All of these details are handled. */
  1420.  
  1421.  
  1422.  
  1423. short            MapMItem(short menuID, short menuItem);
  1424.     /*
  1425.     ** INPUT:    menuID        The menu ID
  1426.     **            menuItem    The menuItem, as returned by the Menu Manager (hard value)
  1427.     ** RESULT:    short        The soft menu value.
  1428.     **
  1429.     ** This function converts a menu item hard-id (one returned by the toolbox) to a
  1430.     ** soft-id (defined in the 'STR#' resource associated with the menu).  If there is
  1431.     ** a 'STR#' resource defined with the same id as the menu, it is assumed to be
  1432.     ** for the purpose of converting hard-id values to soft-id values. */
  1433.  
  1434.  
  1435.  
  1436. short            UnmapMItem(short menuID, short menuItem);
  1437.     /*
  1438.     ** INPUT:    menuID
  1439.     **            menuItem
  1440.     ** RESULT:    short
  1441.     **
  1442.     ** This function is the logical reverse of MapMItem(). */
  1443.  
  1444.  
  1445.  
  1446. OSErr            DoReadDocument(FileRecHndl frHndl);
  1447.     /*
  1448.     ** INPUT:    frHndl
  1449.     ** RESULT:    OSErr
  1450.     **
  1451.     ** DoReadDocument() calls the specific read document procedure for the document.
  1452.     ** The specific procedure is stored in the frHndl field readDocumentProc.  The
  1453.     ** default value for readDocumentProc is ReadDocument().  It is the responsibility
  1454.     ** of the readDocument procedure to call the readDocumentHeader procedure.  This is
  1455.     ** done by calling DoReadDocumentHeader() from within the readDocumentProc. */
  1456.  
  1457.  
  1458.  
  1459. OSErr            DoReadDocumentHeader(FileRecHndl frHndl);
  1460.     /*
  1461.     ** INPUT:    frHndl
  1462.     ** RESULT:    OSErr
  1463.     **
  1464.     ** DoReadDocumentHeader() calls the specific read document header procedure for the
  1465.     ** document.  The specific procedure is stored in the frHndl field
  1466.     ** readDocumentHeaderProc.  The default value for readDocumentHeaderProc
  1467.     ** is DefaultReadDocumentHeader(). */
  1468.  
  1469.  
  1470.  
  1471. OSErr            DefaultReadDocumentHeader(FileRecHndl frHndl);
  1472.     /*
  1473.     ** INPUT:    frHndl
  1474.     ** RESULT:    OSErr
  1475.     **
  1476.     ** This function reads in the default header for a file.  The header information is
  1477.     ** described by the structure DocHeaderInfo.  The typedef for this structure is in the
  1478.     ** file DTS.Lib.h.  This block of header information is saved at the beginning of the
  1479.     ** file.  It is written to the data fork.  If you want the header information saved in
  1480.     ** the resource fork, you will have to have a custom readDocumentHeaderProc and
  1481.     ** writeDocumentHeaderProc.  You can then simply read and write using the resource
  1482.     ** fork, instead of the data fork, as the defaults do. */
  1483.  
  1484.  
  1485.  
  1486. OSErr            DoWriteDocument(FileRecHndl frHndl);
  1487.     /*
  1488.     ** INPUT:    frHndl
  1489.     ** RESULT:    OSErr
  1490.     **
  1491.     ** DoWriteDocument() calls the specific write document procedure for the document.
  1492.     ** The specific procedure is stored in the frHndl field writeDocumentProc.  The
  1493.     ** default value for writeDocumentProc is WriteDocument().  It is the responsibility
  1494.     ** of the writeDocument procedure to call the writeDocumentHeader procedure.  This is
  1495.     ** done by calling DoWriteDocumentHeader() from within the writeDocumentProc. */
  1496.  
  1497.  
  1498.  
  1499. OSErr            DoWriteDocumentHeader(FileRecHndl frHndl);
  1500.     /*
  1501.     ** INPUT:    frHndl
  1502.     ** RESULT:    OSErr
  1503.     **
  1504.     ** DoWriteDocumentHeader() calls the specific write document header procedure
  1505.     ** for the document.  The specific procedure is stored in the frHndl field
  1506.     ** writeDocumentHeaderProc.  The default value for writeDocumentHeaderProc
  1507.     ** is DefaultWriteDocumentHeader(). */
  1508.  
  1509.  
  1510.  
  1511. OSErr            DefaultWriteDocumentHeader(FileRecHndl frHndl);
  1512.     /*
  1513.     ** INPUT:    frHndl
  1514.     ** RESULT:    OSErr
  1515.     **
  1516.     ** This function writes out the default header for a file.  The header information is
  1517.     ** described by the structure DocHeaderInfo.  The typedef for this structure is in the
  1518.     ** file DTS.Lib.h.  This block of header information is saved at the beginning of the
  1519.     ** file.  It is written to the data fork.  If you want the header information saved in
  1520.     ** the resource fork, you will have to have a custom readDocumentHeaderProc and
  1521.     ** writeDocumentHeaderProc.  You can then simply read and write using the resource
  1522.     ** fork, instead of the data fork, as the defaults do. */
  1523.  
  1524.  
  1525.  
  1526. void            DoResizeContent(WindowPtr window, short oldh, short oldv);
  1527.     /*
  1528.     ** INPUT:    window
  1529.     **            oldh
  1530.     **            oldv
  1531.     **
  1532.     ** This function is called when a window has been resized.  It is possible that window
  1533.     ** contents have to be adjusted to match the new window size.  DoResizeContent()
  1534.     ** handles this.  DoResizeContent() uses a procedure stored in the frHndl field
  1535.     ** resizeContentProc.  If resizeContentProc is not nil, then the procedure is called.
  1536.     ** The default value for resizeContentProc is ResizeContent(). */
  1537.  
  1538.  
  1539.  
  1540. void            DoScrollFrame(WindowPtr window, long dx, long dy);
  1541.     /*
  1542.     ** INPUT:    window
  1543.     **            dx
  1544.     **            dy
  1545.     **
  1546.     ** Some applications may need to scroll the "frame" of the document along with the
  1547.     ** document contents.  This is common for applications with rulers, or other similar
  1548.     ** sidebar items.  DoScrollFrame is called when document scrolling has occured.
  1549.     ** DoScrollFrame() uses a procedure stored in the frHndl field scrollFrameProc.
  1550.     ** If scrollFrameProc is not nil, then the procedure is called.  The default value
  1551.     ** for scrollFrameProc is ScrollFrame(). */
  1552.  
  1553.  
  1554.  
  1555. void            DoUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo);
  1556.     /*
  1557.     ** INPUT:    frHndl
  1558.     **            contOrg
  1559.     **            afterUndo
  1560.     **
  1561.     ** This function is called by the hierarchical document package in response to an
  1562.     ** undo/redo operation.  It is called prior to any undo information being applied
  1563.     ** to the document so that you can prepare the document for an undo.  It is also
  1564.     ** called after all undo tasks are performed on the document.  This last call is a
  1565.     ** chance for any additional cleanup that might have to occur.  Commonly this second
  1566.     ** call is used to reimage the document to show the document undone/redone.
  1567.     ** DoUndoFixup() doesn’t actually do the work, as it doesn’t know what kind of
  1568.     ** document it was called for.  It simply looks in the frHndl at the field
  1569.     ** undoFixupProc.  If undoFixupProc is not nil, then the procedure is called.
  1570.     ** The default value for undoFixupProc is UndoFixup(). */
  1571.  
  1572.  
  1573.  
  1574. void            CleanSendBehind(WindowPtr window, WindowPtr afterWindow);
  1575.     /*
  1576.     ** INPUT:    window
  1577.     **            afterUndo
  1578.     **
  1579.     ** This function is exactly what it would seem by the name.  SendBehind() has some
  1580.     ** problems in that it causes too much repainting of windows.  This function allows
  1581.     ** you to change the layer of a window very cleanly.  It also calls HiliteWindows(),
  1582.     ** which walks the window list and adjusts window hilighting for the various types
  1583.     ** of windows.  The top-most of a type is hilited, and all other windows of that
  1584.     ** type are unhilited. */
  1585.  
  1586.  
  1587.  
  1588. void            CleanSendInFront(WindowPtr window, WindowPtr beforeWindow);
  1589.     /*
  1590.     ** INPUT:    window
  1591.     **            beforeWindow
  1592.     **
  1593.     ** Again, this is exactly what it would seem.  See CleanSendBehind() for
  1594.     ** more information. */
  1595.  
  1596.  
  1597.  
  1598. void            HiliteWindows(void);
  1599.     /*
  1600.     ** This function is called to adjust the hilites of all windows.  Since DTS.framework
  1601.     ** supports palettes, there is possibly more than one hilited window.  The window
  1602.     ** manager doesn’t want to play this game, so certain additional functions had to be
  1603.     ** written.  Basically, if you are using palettes, don’t make any window manager calls
  1604.     ** that change window hiliting.  Use CleanSendBehind() and CleanSendInFront().  These
  1605.     ** take care of window shuffling correctly.  Of course, there are calls you can’t
  1606.     ** avoid, such as closing a window.  If you do these operations directly, call
  1607.     ** HiliteWindows() afterwards. */
  1608.  
  1609.  
  1610.  
  1611. void            UnhiliteWindows(void);
  1612.     /*
  1613.     ** This is called to unhilite all windows.  DTS.framework allows for multiple hilited
  1614.     ** windows.  All of them have to be unhilited prior to bringing up a modal dialog or
  1615.     ** alert.  Call this to unhilite all windows, do the modal dialog or alert, and then
  1616.     ** call HiliteWindows() to set the hiliting back to normal. */
  1617.  
  1618.  
  1619.  
  1620. void            DoUpdate(WindowPtr window);
  1621.     /*
  1622.     ** INPUT:    window
  1623.     **
  1624.     ** This is called when an update event is received for a window.  First, the
  1625.     ** updateRgn is separated into two parts.  Part 1 holds the window frame area,
  1626.     ** if any.  This is the area that might hold the scrollbars, grow icon, and
  1627.     ** any other application-specific frame parts.  This is drawn first.  Once
  1628.     ** this is done, the remainder of the updateRgn is drawn.  This allows us to
  1629.     ** handle all of the frame clipping without using the clipRgn.  By freeing up
  1630.     ** the clipRgn, we allow the application to use it without having to share. */
  1631.  
  1632.  
  1633.  
  1634. void            DoSetCursor(Cursor *cursor);
  1635.     /*
  1636.     ** INPUT:    cursor
  1637.     **
  1638.     ** Call this function to correctly set the cursor and to inform DTS.framework that
  1639.     ** you have specifically set the cursor.  This is used when you temporarily want to
  1640.     ** set the cursor, such as just before a slow operation.  For a slow operation, you
  1641.     ** may want to put up the wait cursor.  Use DoSetCursor() for this, and then when the
  1642.     ** operation is over and program control returns to the main event loop, the cursor
  1643.     ** will be recalculated to the current cursor for the mouse position. */
  1644.  
  1645.  
  1646.  
  1647. CursPtr            DoSetResCursor(short crsrID);
  1648.     /*
  1649.     ** INPUT:    crsrID
  1650.     ** RESULT:    CursPtr
  1651.     **
  1652.     ** This function serves the same purpose as DoSetCursor, except that you pass in
  1653.     ** a resID, instead of a cursor pointer.  The resource is loaded, the cursor is then
  1654.     ** copied into permanent memory, and then DoSetCursor is called with a pointer to
  1655.     ** the cursor image. */
  1656.  
  1657.  
  1658.  
  1659. void            DoWindowCursor(void);
  1660.     /*
  1661.     ** Call this function to calculate what the cursor should be for various windows.
  1662.     ** The result of this function is to set the cursor based on the current mouse
  1663.     ** position.  In addition to setting the cursor, the cursor region is calculated.
  1664.     ** The cursor region is kept in the global variable gCursorRgn.
  1665.     ** This function walks the window list, and for each document window, it calls the
  1666.     ** window’s cursor handling procedure.  The cursor handling procedure is stored in
  1667.     ** the frHndl field windowCursorProc.
  1668.     ** Here are the rules for cursor and gCursorRgn determination:
  1669.     **
  1670.     ** 1) See if the mouse position is currently inside the gCursorRgn.  If so, leave.
  1671.     ** 2) Since the mouse position is outside the current gCursorRgn, we need to
  1672.     **    recalculate the cursor.  Set the gCursorRgn to wide-open.  From now on, we
  1673.     **    will eliminate areas from gCursorRgn that don’t apply to the new mouse
  1674.     **    location and new cursor.
  1675.     ** 3) For each visible window (starting with the front window):
  1676.     **    a) If the windowCursorProc is nil and the mouse position is over the structure
  1677.     **       region of the window, set the cursor to an arrow and intersect the gCursorRgn
  1678.     **       with the structure region of the window.  This limits the cursor to the area
  1679.     **       of the window that is visible.
  1680.     **    b) If the windowCursorProc is nil and the mouse position is outside the
  1681.     **       structure region of the window, diff out the structure region from
  1682.     **       gCursorRgn and proceed to the next visible window in the window list.
  1683.     **    c) If the windowCursorProc is not nil, call the procedure.  Note that the
  1684.     **       procedure is called whether or not the mouse location is over the window.
  1685.     **       This is to allow the procedure to determine if it should be the last
  1686.     **       window checked.
  1687.     **       The proc’s job is as follows:
  1688.     **       1) If the cursor is over a position that is determined by the window, then
  1689.     **          the proc removes other areas from gCursorRgn.  Note that it should not
  1690.     **          simply set the area to what it "thinks" is the correct area.  This window
  1691.     **          may not be the front-most.  Other windows will have already been
  1692.     **          subtracted from gCursorRgn.  The resultant gCursorRgn is the correct
  1693.     **          cursor area, and should be passed to WaitNextEvent calls in the
  1694.     **          application.  Also, the cursor should be set to the correct cursor, of
  1695.     **          course.  You should also return true, as the cursor has been determined.
  1696.     **          The rule of thumb for what you should do to the gCursorRgn is that you
  1697.     **          should calculate the cursor region as if the window was the top window.
  1698.     **          Once this is done, intersect the gCursorRgn with this region.  The result
  1699.     **          should be stored in gCursorRgn.
  1700.     **          Since you determined a cursor and gCursorRgn in this case, you should
  1701.     **          return true.  Returning true indicates to DoWindowCursor() that the
  1702.     **          cursor has been determined, and that it should stop processing windows.
  1703.     **       2) If the cursor is not over a position for this window, then you should
  1704.     **          return.  You will either pass back true or false.  If you don’t wish
  1705.     **          windows behind this window to have a shot at cursor determination, then
  1706.     **          return true.  This states that the cursor is "determined".  It is, in the
  1707.     **          sense that no further determination will occur.  If you return false, then
  1708.     **          other windows get a shot at determining the cursor.  If there are no other
  1709.     **          windows, then the cursor is set to an arrow, and gCursorRgn is set to the
  1710.     **          area that is outside all windows for the application.
  1711.     **          (Common case:)  If you don’t want windows behind this one to determine
  1712.     **          the cursor:
  1713.     **          a) Set the cursor to an arrow.  Since you are outside this window, the
  1714.     **             cursor should be an arrow.  The cursor may be over the desktop or
  1715.     **             menubar, or some other window that isn’t the top-most window.  All of
  1716.     **             these cases should have an arrow cursor.  Also, you need to diff out
  1717.     **             the window’s structure region from gCursorRgn.  By diffing it out,
  1718.     **             you will get mouse-moved events when the cursor is moved back over
  1719.     **             this window.
  1720.     **          b) Return true.  This tells DoWindowCursor() that the cursor has
  1721.     **             been determined.
  1722.     **          (Uncommon case:)  If you want windows behind this one to possibly
  1723.     **             determine the cursor:  Return false.  That’s it.  DTS.framework will
  1724.     **             automatically remove the structure region for this window from
  1725.     **             gCursorRgn if you return false.  If you return false, DTS.framework
  1726.     **             proceeds to the next window, if there is one.  If there are no more
  1727.     **             windows behind this one, then DTS.framework sets the cursor to an
  1728.     **             arrow, and the resultant gCursorRgn will have all of the structure
  1729.     **             regions for the windows removed from it. */
  1730.  
  1731.  
  1732.  
  1733. WindowPtr        FrontWindowOfType(long wkind, Boolean firstVis);
  1734.     /*
  1735.     ** INPUT:    wkind
  1736.     **            firstVis
  1737.     ** RESULT:    WindowPtr
  1738.     **
  1739.     ** Since DTS.framework supports three distinct categories of windows
  1740.     ** (document/palette/dialog), it is often necessary to get the front-most
  1741.     ** window of a certain type.  Use this function to accomplish this.  Basically,
  1742.     ** this takes the place of FrontWindow() if you have more than one category of
  1743.     ** window in your application. */
  1744.  
  1745.  
  1746.  
  1747. short            HCenteredAlert(short alertID, WindowPtr relatedWindow,
  1748.                                ModalFilterUPP filter);
  1749.     /*
  1750.     ** INPUT:    alertID
  1751.     **            relatedWindow
  1752.     **            filter
  1753.     ** RESULT:    short
  1754.     **
  1755.     ** This function gets an alert, and handles hiliting of windows correctly.
  1756.     ** The reason for this function is that there may be more than one hilited
  1757.     ** window due to the possibility of floating palettes.  The calls to UnhiliteWindows
  1758.     ** and HiliteWindows make sure that while the alert is up, there are no other
  1759.     ** hilited windows. */
  1760.  
  1761.  
  1762.  
  1763. OSErr            GetWindowFormats(void);
  1764.     /*
  1765.     ** RESULT:    OSErr
  1766.     **
  1767.     ** This function gets the application window formats that were created with
  1768.     ** the AppsToGo application editor.  The window formats are stored in the resource
  1769.     ** 'WFMT' id #128.  They are first read in, and then they are unflattened
  1770.     ** by calling HReadWindowFormats(). */
  1771.  
  1772.  
  1773.  
  1774. OSErr            HReadWindowFormats(Handle wfmt);
  1775.     /*
  1776.     ** INPUT:    wfmt
  1777.     ** RESULT:    OSErr
  1778.     **
  1779.     ** This function is called to unflatten a window-format handle into separate
  1780.     ** hierarchical document objects.  The assumption is that there is only one
  1781.     ** of these multiple window definitions, and therefore if there is already
  1782.     ** one in the global gWindowFormats, it is disposed of.  This is exactly the
  1783.     ** behavior needed by the AppsToGo application editor. */
  1784.  
  1785.  
  1786.  
  1787. OSErr            GetSeparateWFMT(OSType sftype, short *numAdded);
  1788.     /*
  1789.     ** INPUT:    sftype
  1790.     ** OUTPUT:    numAdded
  1791.     ** RESULT:    OSErr
  1792.     **
  1793.     ** This function is called to add (or remove) a window-format resource definition
  1794.     ** to the global gWindowFormats.  The purpose of this is to be able to break up the
  1795.     ** single 'WFMT' id #128 resource, which may get quite large for some applications.
  1796.     ** NewDocumentWindow() and AddControlSet() automatically call GetSeparateWFMT() 
  1797.     ** for you.  If the document definition is in a separate 'WFMT' resource,
  1798.     ** then that definition is added to gWindowFormats long enough to be used, and then
  1799.     ** it is removed.  The 'WFMT' resource can be of any id other than 128, and must be
  1800.     ** named with the DocType, such as ABOT for the about box.  (The name must always be
  1801.     ** 4 characters.)  Passing in 0 for the DocType (OSType) disposes of however many
  1802.     ** were added.  The number added is returned from the first time it is called. */
  1803.  
  1804.  
  1805.  
  1806. OSErr            AddControlSet(WindowPtr window, OSType sftype, short visMode,
  1807.                               short xoffset, short yoffset, CObjCtlHndl cco);
  1808.     /*
  1809.     ** INPUT:    window
  1810.     **            sftype
  1811.     **            visMode
  1812.     **            xoffset
  1813.     **            yoffset
  1814.     ** IN/OUT    cco
  1815.     ** RESULT:    OSErr
  1816.     **
  1817.     ** This function adds a set of controls (and sets referenced by that set) to the
  1818.     ** window.  The control sets are created with the AppsToGo application editor. */
  1819.  
  1820.  
  1821.  
  1822. ControlHandle    MakeControl(WindowPtr window, TreeObjHndl cobj,
  1823.                             short visMode, short xoffset, short yoffset);
  1824.     /*
  1825.     ** INPUT:    window
  1826.     **            cobj
  1827.     **            visMode
  1828.     **            xoffset
  1829.     **            yoffset
  1830.     ** RESULT:    ControlHandle
  1831.     **
  1832.     ** This function is used to create a control based on the control definition object.
  1833.     ** The control definition objects are created with the AppsToGo application editor. */
  1834.  
  1835.  
  1836.  
  1837. CObjCtlHndl        GetControlSet(WindowPtr window, OSType sftype, ControlHandle *retDataCtl);
  1838.     /*
  1839.     ** INPUT:    window
  1840.     **            sftype
  1841.     ** OUTPUT:    retDataCtl
  1842.     ** RESULT:    CObjCtlHndl
  1843.     **
  1844.     ** This function is called to return the handle of the Data control that has
  1845.     ** a reference to all of the controls in the control set.  Once you get the
  1846.     ** Data control, you can then look at the data in the control to get the handle
  1847.     ** of the controls within the control set. */
  1848.  
  1849.  
  1850.  
  1851. void            DisplayControlSet(WindowPtr window, OSType sftype, short visMode);
  1852.     /*
  1853.     ** INPUT:    window
  1854.     **            sftype
  1855.     **            visMode
  1856.     **
  1857.     ** This function is used to show or hide a set of controls. */
  1858.  
  1859.  
  1860.  
  1861. void            DrawControlSet(WindowPtr window, OSType sftype);
  1862.     /*
  1863.     ** INPUT:    window
  1864.     **            sftype
  1865.     **
  1866.     ** This function is used to draw a set of controls. */
  1867.  
  1868.  
  1869.  
  1870. void            DisposeControlSet(WindowPtr window, OSType sftype);
  1871.     /*
  1872.     ** INPUT:    window
  1873.     **            sftype
  1874.     **
  1875.     ** This function is used to dispose a set of controls. */
  1876.  
  1877.  
  1878.  
  1879. void            DisposeControlFromSet(ControlHandle ctl, OSType sftype);
  1880.     /*
  1881.     ** INPUT:    window
  1882.     **            sftype
  1883.     **
  1884.     ** This function is used to dispose a single control from a control set.  If it
  1885.     ** is the last control in the set, the dataCtl which contains the set
  1886.     ** information is also disposed of. */
  1887.  
  1888. Boolean            DoAdjustMBARMenus(WindowPtr window, short menuBarID);
  1889.     /*
  1890.     ** INPUT:    window
  1891.     **            menuBarID
  1892.     ** RESULT:    Boolean
  1893.     **
  1894.     ** This fuction is called to adjust all of the menus in the designated MBAR. 
  1895.     ** The functions gets each menu handle, and then disables all of the menu items
  1896.     ** for that menu.  It then calls the application to give the application the
  1897.     ** chance to enable the appropriate menu items. */
  1898.  
  1899.  
  1900.  
  1901. OSErr            OpenRuntimeOnlyAutoNewWindows(void);
  1902.     /*
  1903.     ** RESULT:    OSErr
  1904.     **
  1905.     ** This function is used to open all of the windows that are correctly designated
  1906.     ** with the AppsToGo application editor.  You should call this in your application
  1907.     ** at startup time if your application is editable with the AppsToGo
  1908.     ** application editor. */
  1909.  
  1910.  
  1911.  
  1912. OSErr            NewDocumentWindow(FileRecHndl *frHndl, OSType sftype, Boolean incTitleNum);
  1913.     /*
  1914.     ** INPUT:    sftype
  1915.     **            incTitleNum
  1916.     ** OUTPUT:    frHndl
  1917.     ** RESULT:    OSErr
  1918.     **
  1919.     ** This call can be done as two separate calls.  However, this function does both
  1920.     ** functions of creating the document, and then giving the document a window.  It
  1921.     ** also handles errors and puts up an error window if something goes wrong. */
  1922.  
  1923.  
  1924.  
  1925. OSErr            OpenDocumentWindow(FileRecHndl *frHndl, FSSpecPtr fileToOpen,
  1926.                                    char permission);
  1927.     /*
  1928.     ** INPUT:    fileToOpen
  1929.     **            permission
  1930.     ** OUTPUT:    frHndl
  1931.     ** RESULT:    OSErr
  1932.     **
  1933.     ** This call can be done as two separate calls.  However, this function does both
  1934.     ** functions of creating the document, and then giving the document a window.  It
  1935.     ** also handles errors and puts up an error window if something goes wrong. */
  1936.  
  1937.  
  1938.  
  1939. /**************************************/
  1940. /************** Window.c **************/
  1941. /**************************************/
  1942.  
  1943.  
  1944.  
  1945. /* •• DTS.Lib..framework calls these. •• */
  1946. /* See the sample application AppWannabe for an explanation of these functions. */
  1947.  
  1948. void        CalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn);
  1949. void        ContentClick(WindowPtr window, EventRecord *event, Boolean firstCLick);
  1950. Boolean        ContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  1951. void        DrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate);
  1952. OSErr        FreeDocument(FileRecHndl frHndl);
  1953. OSErr        FreeWindow(FileRecHndl frHndl, WindowPtr window);
  1954. OSErr        ImageDocument(FileRecHndl frHndl);
  1955. OSErr        InitContent(FileRecHndl frHndl, WindowPtr window);
  1956. OSErr        ReadDocument(FileRecHndl frHndl);
  1957. void        ResizeContent(WindowPtr window, short oldh, short oldv);
  1958. void        ScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv);
  1959. void        UndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo);
  1960. Boolean        WindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  1961. void        WindowGoneFixup(WindowPtr window);
  1962. OSErr        WriteDocument(FileRecHndl frHndl);
  1963. OSErr        DoOpenApplication(void);
  1964. Boolean        AdjustMenuItems(WindowPtr window, short menuID);
  1965. Boolean        DoMenuItem(WindowPtr window, short menuID, short menuItem);
  1966.  
  1967.  
  1968.  
  1969. /********************************************/
  1970. /************** WindowDialog.c **************/
  1971. /********************************************/
  1972.  
  1973.  
  1974.  
  1975. /* •• DTS.Lib..framework calls these. •• */
  1976. /* See the sample application AppWannabe for an explanation of these functions. */
  1977.  
  1978. void        DialogCalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn);
  1979. void        DialogContentClick(WindowPtr window, EventRecord *event, Boolean firstClick);
  1980. Boolean        DialogContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  1981. void        DialogDrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate);
  1982. OSErr        DialogFreeDocument(FileRecHndl frHndl);
  1983. OSErr        DialogFreeWindow(FileRecHndl frHndl, WindowPtr window);
  1984. OSErr        DialogImageDocument(FileRecHndl frHndl);
  1985. OSErr        DialogInitContent(FileRecHndl frHndl, WindowPtr window);
  1986. void        DialogResizeContent(WindowPtr window, short oldh, short oldv);
  1987. void        DialogScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv);
  1988. void        DialogUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo);
  1989. Boolean        DialogWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  1990. void        DialogWindowGoneFixup(WindowPtr window);
  1991. Boolean        DialogAdjustMenuItems(WindowPtr window, short menuID);
  1992. Boolean        DialogDoMenuItem(WindowPtr window, short menuID, short menuItem);
  1993.  
  1994.  
  1995.  
  1996. /*********************************************/
  1997. /************** WindowPalette.c **************/
  1998. /*********************************************/
  1999.  
  2000.  
  2001.  
  2002. /* •• DTS.Lib..framework calls these. •• */
  2003. /* See the sample application AppWannabe for an explanation of these functions. */
  2004.  
  2005. void        PaletteCalcFrameRgn(FileRecHndl frHndl, WindowPtr window, RgnHandle rgn);
  2006. void        PaletteContentClick(WindowPtr window, EventRecord *event, Boolean firstCLick);
  2007. Boolean        PaletteContentKey(WindowPtr window, EventRecord *event, Boolean *passThrough);
  2008. void        PaletteDrawFrame(FileRecHndl frHndl, WindowPtr window, Boolean activate);
  2009. OSErr        PaletteFreeDocument(FileRecHndl frHndl);
  2010. OSErr        PaletteFreeWindow(FileRecHndl frHndl, WindowPtr window);
  2011. OSErr        PaletteImageDocument(FileRecHndl frHndl);
  2012. OSErr        PaletteInitContent(FileRecHndl frHndl, WindowPtr window);
  2013. void        PaletteResizeContent(WindowPtr window, short oldh, short oldv);
  2014. void        PaletteScrollFrame(FileRecHndl frHndl, WindowPtr window, long dh, long dv);
  2015. void        PaletteUndoFixup(FileRecHndl frHndl, Point contOrg, Boolean afterUndo);
  2016. Boolean        PaletteWindowCursor(FileRecHndl frHndl, WindowPtr window, Point globalPt);
  2017. void        PaletteWindowGoneFixup(WindowPtr window);
  2018.  
  2019.  
  2020.  
  2021. #endif
  2022.